<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'form/guardable_form.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/integer_positive/form_field_integer_positive.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/text/form_field_text.class.php');
require_once(TANGRA_MAIN_DIR.'/form/static_html_form_generator.class.php');


class Settings_Attachments_Form extends Guardable_Form {
	function __construct() {
		parent::__construct('settings_attachments', 'admin/modules/tangra_cms/settings/settings_content_edit.php');

		$f_max_size = new Form_Field_Integer_Positive('max_size', false, true, 12);
		$this->add_field($f_max_size);

		$f_max_total_size = new Form_Field_Integer_Positive('max_total_size', false, true, 12);
		$this->add_field($f_max_total_size);

		$f_forbidden_extensions = new Form_Field_Text('forbidden_extensions', true, 255);
		$f_forbidden_extensions->add_potential_error('invalid_list');
		$this->add_field($f_forbidden_extensions);

		$f_upload_path = new Form_Field_Text('upload_path', false, 255);
		$f_upload_path->add_potential_error('invalid_path');
		$this->add_field($f_upload_path);
	}


	public function generate_html() {
		$html_gen = new Static_HTML_Form_Generator($this, 'modules/form_html_tpl_static_ajax_metallic_en', 'en');
		$html_gen->create_default_tpl_maps();
		$html_gen->change_field_p_error_map_entry('forbidden_extensions', 'invalid_list', 'modules/tangra_cms/forms/field_errors/settings_content/field_error_invalid_list.tpl');
		$html_gen->change_field_p_error_map_entry('upload_path', 'invalid_path', 'modules/tangra_cms/forms/field_errors/settings_attributes/field_error_invalid_path.tpl');

		printbr('<pre>');
		printbr(htmlentities($html_gen->get_static_html()));
		printbr('</pre>');
	}
}

